package d0317;

import java.util.Scanner;

public class StopIoWaitThread {
    public static void main(String[] args) {
        IoWaitThread stopIoWaitThread = new IoWaitThread();
        System.out.println("线程启动");
        stopIoWaitThread.start();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        stopIoWaitThread.interrupt();
    }
}
class IoWaitThread extends Thread{
    Scanner scanner = new Scanner(System.in);
    private boolean flag=true;
    @Override
    public void run(){
        while (flag){
            System.out.println("等待用户输入");
            scanner.next();
        }
    }
    public void stopThread(){
        flag = false;
    }
}